<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>员工管理</title>
    <link href='https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css' rel='stylesheet'>
    <script type="text/javascript" src="/staticimg/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript">

        // 删除单行信息
        function deleteOne(obj,uid,pageSize){
            //此处alert,为提示框,这confirm为确认就删,取消就是不删除
            //AJAX也可以用最下面哪个简单版的
            if (confirm("确定删除~~~")) {
                //发送AJAX请求
                $.ajax({
                    url:"/deletepenson?pid="+uid+"&pageSize="+pageSize,
                    data:null,
                    type:"post",
                    dataType:"json",
                    success:function (rs) {    //rs用来接收返回的结果
                        if (rs.code==0){
                            //删除成功
                            $(obj).parent().parent().remove();
                        } else {
                            //删除失败
                            alert(rs.msg);
                        }
                    }
                })
            }
        }

        function add(){
            location.href="/getDept";
        }

        function tosub() {
            //设置隐藏值
            document.getElementById("mymethod").value="delete";
            //提交表单
            // 第一种:document.getElementById("myform").submit();
            //第二种：此处意为选择第二个form表单提交！！！
            document.forms[1].submit();
        }
        //全选和反选
        function ddd() {
            var allsel = document.getElementsByName("empid");/* uid为复选框的name属性值 */
            for ( var i = 0; i < allsel.length; i++) {
                //此处设置为选中或者不选中
                allsel[i].checked = !allsel[i].checked;
            }
        }

        function todaochu() {
            //设置隐藏域的值
            document.getElementById("mymethod").value="daochu";
            //提交表单
            document.forms[1].submit();
        }
    </script>

</head>
<body>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <h3 class="text-center text-success">
                员工管理
            </h3>
            <form>
                <form action="getAllPerson" method="get">
                <fieldset>
                    <legend>筛选查询</legend>
                    <label>姓名</label><input type="text" name="username" value="${username!}"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <label>所属部门</label><input type="text" name="deptname" value="${deptname!}"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <label>创建时间</label><input type="date" name="timename" />
<#--                                              value="${timename!?string('yyyy-MM-dd')}"/>&nbsp;&nbsp;&nbsp;-->
                    <button type="submit" class="btn">查询</button>
                </form>
                    <span style="float: right; margin-right: 8px; font-weight: bold;">
                        <span onclick="todaochu()" style="color: blue; cursor: pointer">【导出数据】</span>
<#--  此处设置字体颜色为蓝色，同时当鼠标移动到这里时候，鼠标变成小手，相当于一个假的a标签-->
                        <span onclick="tosub()" style="color: blue; cursor: pointer">【批量删除】</span>
                    </span>
                </fieldset>
            </form>
            <br>
            <button class="btn btn-primary btn-block" type="button" onclick="add()">新增</button>

            <form id="myform" action="deletebyids" method="post">
                <input type="hidden" name="method" id="mymethod">
                <table class="table">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th><input type="checkbox" onclick="ddd()"></th>
                        <th>员工账号</th>
                        <th>姓名</th>
                        <th>手机号</th>
                        <th>所属部门</th>
                        <th>职位</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>

                    <tbody>
                    <#list pageinfo.list as student>
                        <tr class="success">
                            <td>${student.pid}</td>
                            <td><input type="checkbox" name="empid" value="${student.pid}"></td>
                            <td>${student.pzhanghao}</td>
                            <td>${student.pname}</td>
                            <td>${student.pnumber}</td>
                            <td>${student.dname}</td>
                            <td>${student.uname}</td>
                            <td>${student.pdate?string('yyyy-MM-dd')}</td>
                            <td>
                                <a href="/updatepassword1?pid=${student.pid}">重置密码</a>
                                &nbsp;&nbsp;&nbsp;
                                <a href="beforeupdateperson?pid=${student.pid}">编辑</a>
                                &nbsp;&nbsp;&nbsp;
<#--                                this代表本对象-->
                                <a onclick="deleteOne(this,${student.pid},${pageSize})">删除</a>
                                &nbsp;&nbsp;&nbsp;
                            </td>
                        </tr>
                    </#list>

                    </tbody>
                </table>
            </form>

            <ul class="pagination">
                <form action="/getAllPerson" method="post">
                    <label class="control-label">每页显示：</label>
                    <div>
                        <#--                    value=""-->
                        <select class="span6 m-wrap" name="pageSize" id="platform" style="width:178px;" >
                            <option value="1" [#if pageSize == 1]selected="selected"[/#if]>1</option>
                            <option value="2" [#if pageSize == 2]selected="selected"[/#if]>2</option>
                            <option value="3" [#if pageSize == 3]selected="selected"[/#if]>3</option>
                            <option value="4" [#if pageSize == 4]selected="selected"[/#if]>4</option>
                            <option value="5" [#if pageSize == 5]selected="selected"[/#if]>5</option>
                            <option value="6" [#if pageSize == 6]selected="selected"[/#if]>6</option>
                        </select>
                    </div>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-default btn-primary" href="/getAllUsers?index=1">刷新</button>
                </form>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                共${pageinfo.pages}页/${pageinfo.total}条数据

                <#if pageinfo.hasPreviousPage>
                <#--                    <li>-->
                <#--                        <a href="javascript:;" onclick="location.href='/debt/list?index=${pageInfo.nextPage}'">下一页</a>-->
                <#--                    </li>-->
                <#--                    也可以写为楼下-->
                    <li>
                        <a href="/getAllPerson?index=1&pageSize=${pageSize}">首页</a>
                    </li>
                    &nbsp;&nbsp;&nbsp;
                    <li>
                        <a href="/getAllPerson?index=${index1-1}&pageSize=${pageSize}">上一页</a>
                    </li>
                </#if>
                &nbsp;&nbsp;&nbsp;
                <#list 1..pageinfo.pages as pages>
                    <li>
                        &nbsp;&nbsp;&nbsp;
                        <a href="/getAllPerson?index=${pages}&pageSize=${pageSize}">${pages}</a>
                    </li>
                </#list>
                <#if pageinfo.pageNum lt pageinfo.pages>
                    <li>
                        <a href="/getAllPerson?index=${index1+1}&pageSize=${pageSize}">下一页</a>
                    </li>
                    <li>
                        <a href="/getAllPerson?index=${pageinfo.pages}&pageSize=${pageSize}">尾页</a>
                    </li>
                </#if>
                <br>
                <br>
                <br>
                <form action="/getAllPerson" method="post">
                    跳至<input type="text" id="jump" >页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-default btn-primary" href="/getAllUsers?index=1">刷新</button>
                </form>

            </ul>
        </div>
    </div>
</div>
</body>
</html>